<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<style type="text/css">
			#box{
				height: 180px;
				background: red;
			}
		</style>
		<script type="text/javascript">
			window.onload = function(){
				//1.抓元素
				var box = document.getElementById("box");
				var btn = document.getElementById("btn");
				//2.给btn加点击事件
				btn.onclick = function(){
					//3.获得旧元素宽度
					var oldWidth = box.style.width;
					//4.设置一个新宽度
					//parseInt()将字符串转为整型
					var newWidth = parseInt(oldWidth) + 20;
					//5.将新宽度赋值回去
					box.style.width = newWidth + 'px';
				}
			}
		</script>
	</head>
	<body>
		<!--回去练习 点击元素变宽动画-->
		<div id="box" style="width: 180px;"></div>
		<button id="btn">点我呀~</button>
	</body>
</html>
